package com.zx.www.volunteersystem.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/AI")
@Tag(name = "AI接口")
public class AIController {
    @Autowired
    @Qualifier("openAiChatModel")
    private ChatModel chatModel;

    @GetMapping("/v1")
    @Operation(summary = "聊天调用")
    public String ollamaChat(@RequestParam String msg) {
        return chatModel.call(msg);
    }

    @GetMapping("/v2")
    @Operation(summary = "聊天流式调用")
    public Flux<String> ollamaChat2(@RequestParam String msg) {
        Flux<String> stream = chatModel.stream(msg);
        return stream;
    }
}